#include "dlog.h"
#include <QSpinBox>     //输入
#include <QLabel>
#include <QPushButton>

Dlog::Dlog(int row, int col, int mine)
{
    //行数 列数 雷数
    QLabel * label1 = new QLabel("行数：", this);
    label1->setGeometry(20, 20, 50, 30);
    QLabel * label2 = new QLabel("列数：", this);
    label2->setGeometry(20, 50, 50, 30);
    QLabel * label3 = new QLabel("雷数：", this);
    label3->setGeometry(20, 80, 50, 30);

    //输入框
    QSpinBox * spin1 = new QSpinBox(this);
    spin1->setGeometry(70, 20, 70, 30);
    spin1->setRange(1, 20);
    spin1->setValue(row);
    QSpinBox * spin2 = new QSpinBox(this);
    spin2->setGeometry(70, 50, 70, 30);
    spin2->setRange(1, 40);
    spin2->setValue(col);
    QSpinBox * spin3 = new QSpinBox(this);
    spin3->setGeometry(70, 80, 70, 30);
    spin3->setRange(1, 800);
    spin3->setValue(mine);

    //创建按钮
    QPushButton * btn1 = new QPushButton("确定", this);
    btn1->setGeometry(155, 30, 50, 30);
    QPushButton * btn2 = new QPushButton("取消", this);
    btn2->setGeometry(155, 70, 50, 30);

    //确定
    connect(btn1, &QPushButton::clicked, [=](){
        this->chooseRow = spin1->value();
        this->chooseCol = spin2->value();
        this->chooseMine = spin3->value();
        this->isChoose = true;
        this->close();
    });
    //取消
    connect(btn2, &QPushButton::clicked, [=](){
        this->close();
    });
}
